﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    public class CanGongDetail
    {
        private int _Sec;
        [DataMember]
        public int Sec
        {
            get { return _Sec; }
            set { _Sec = value; }
        }
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private string _Name;
        [DataMember]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        private string _CardNO;
        [DataMember]
        public string CardNO
        {
            get { return _CardNO; }
            set { _CardNO = value; }
        }
        private string _OldDuty;
        [DataMember]
        public string OldDuty
        {
            get { return _OldDuty; }
            set { _OldDuty = value; }
        }
        private string _Political;
        [DataMember]
        public string Political
        {
            get { return _Political; }
            set { _Political = value; }
        }
        private string _GuoDuStyle;
        [DataMember]
        public string GuoDuStyle
        {
            get { return _GuoDuStyle; }
            set { _GuoDuStyle = value; }
        }
        private string _Demo;
        [DataMember]
        public string Demo
        {
            get { return _Demo; }
            set { _Demo = value; }
        }
        /// <summary>
        /// 0为暂存，1为提交，2为确认，3为退回
        /// </summary>
        private int _Status;
        [DataMember]
        public int Status
        {
            get { return _Status; }
            set { _Status = value; }
        }
        private string _StatusString;
        [DataMember]
        public string StatusString
        {
            get { return _StatusString; }
            set { _StatusString = value; }
        }
        private DateTime? _GuoDuDate;
        [DataMember]
        public DateTime? GuoDuDate
        {
            get { return _GuoDuDate; }
            set { _GuoDuDate = value; }
        }

        private int _OrgID;
        [DataMember]
        public int OrgID
        {
            get { return _OrgID; }
            set { _OrgID = value; }
        }
        private string _Gender;
        [DataMember]
        public string Gender
        {
            get { return _Gender; }
            set { _Gender = value; }
        }
        private DateTime? _Birthday;
        [DataMember]
        public DateTime? Birthday
        {
            get { return _Birthday; }
            set { _Birthday = value; }
        }
        private bool isselected = false;
        [DataMember]
        public bool IsSelected
        {
            get { return isselected; }
            set { isselected = value; }
        }
        public static CanGongDetail FillEntity(DataRow dr)
        {
            CanGongDetail right = new CanGongDetail();
            if (dr.Table != null && dr.Table.Columns.Contains("Sec")) if (!string.IsNullOrEmpty(dr["Sec"].ToString())) right.Sec = Convert.ToInt32(dr["Sec"]);
            if (dr.Table != null && dr.Table.Columns.Contains("ID")) if (!string.IsNullOrEmpty(dr["ID"].ToString())) right.ID = Convert.ToInt32(dr["ID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("Status")) 
                if (!string.IsNullOrEmpty(dr["Status"].ToString()))
                {
                    right.Status = Convert.ToInt32(dr["Status"]);
                    if (right.Status == 0) right.StatusString = "暂存";
                    if (right.Status == 1) right.StatusString = "提交";
                    if (right.Status == 2) right.StatusString = "已确认";
                    if (right.Status == 3) right.StatusString = "退回";
                }

            if (dr.Table != null && dr.Table.Columns.Contains("CardNO")) if (!string.IsNullOrEmpty(dr["CardNO"].ToString())) right.CardNO = dr["CardNO"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("OldDuty")) if (!string.IsNullOrEmpty(dr["OldDuty"].ToString())) right.OldDuty = dr["OldDuty"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("Political")) if (!string.IsNullOrEmpty(dr["Political"].ToString())) right.Political = dr["Political"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("GuoDuStyle")) if (!string.IsNullOrEmpty(dr["GuoDuStyle"].ToString())) right.GuoDuStyle = dr["GuoDuStyle"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("Name")) if (!string.IsNullOrEmpty(dr["Name"].ToString())) right.Name = dr["Name"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("Demo")) if (!string.IsNullOrEmpty(dr["Demo"].ToString())) right.Demo = dr["Demo"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("GuoDuDate")) if (!string.IsNullOrEmpty(dr["GuoDuDate"].ToString()) && Convert.ToDateTime(dr["GuoDuDate"]) != Convert.ToDateTime("1900-01-01")) right.GuoDuDate = Convert.ToDateTime(dr["GuoDuDate"]);
            if (dr.Table != null && dr.Table.Columns.Contains("OrgID")) if (!string.IsNullOrEmpty(dr["OrgID"].ToString())) right.OrgID = Convert.ToInt32(dr["OrgID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("Gender")) if (!string.IsNullOrEmpty(dr["Gender"].ToString())) right.Gender = dr["Gender"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("Birthday")) if (!string.IsNullOrEmpty(dr["Birthday"].ToString()) && Convert.ToDateTime(dr["Birthday"]) != Convert.ToDateTime("1900-01-01")) right.Birthday = Convert.ToDateTime(dr["Birthday"]);
            
            return right;
        }
    }
}
